﻿using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using UnityEngine;

public class TestWeb : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    [ContextMenu("TestGoogle")]
    void TestGoogle()
    {
        HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create("http://www.google.com" );
        req.Method = "GET"; 

        using (WebResponse wr = req.GetResponse())
        {
            var resStream = wr.GetResponseStream();
            //在这里对接收到的页面内容进行处理 

            using (StreamReader reader = new StreamReader(resStream, Encoding.UTF8))
            {
                var responseContent = reader.ReadToEnd().ToString();
                GameDebug.LogError($"response : {responseContent}");
            }
        }
        
    }
    // Update is called once per frame
    void Update()
    {
        
    }
}
